package com.retail.lottery.colalottery.utils;

import java.util.Base64;

public class Base64Utils {

    public static String removeEndSalt(String saltedString, String salt) {
        if (saltedString.endsWith(salt)) {
            return saltedString.substring(0, saltedString.length() - salt.length());
        }
        return null;
    }

    private static String decodeRequestParams(String query) {
        byte[] decodedBytes = Base64.getDecoder().decode(query);
        return new String(decodedBytes);
    }

    public static String decodeParams(String saltedMessage, String salt) {
        String saltedString = decodeRequestParams(saltedMessage);
        return removeEndSalt(saltedString, salt);
    }

}
